package das_java_forum_ide;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JList;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.UIManager;

import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.Properties;

import javax.swing.JToggleButton;
import javax.swing.JProgressBar;
import javax.swing.AbstractListModel;
import javax.swing.ImageIcon;

public class Worckplace extends JDialog {

	private final JPanel contentPanel = new JPanel();
	private JTextField textField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
			
			Worckplace dialog = new Worckplace();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public Worckplace() {
		setTitle("Arbeitsplatz W\u00E4hlen");
		setBounds(100, 100, 549, 222);
		getContentPane().setLayout(null);
		contentPanel.setBounds(0, 0, 1, 229);
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel);
		contentPanel.setLayout(null);
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setBounds(0, 151, 518, 33);
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane);
			{
				JButton okButton = new JButton("OK");
				okButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						
						Main m = new Main();
						m.WorkingDir=textField.getText();
						m.setVisible(true);
						m.loadProjekts();
						m.pathlbl.setText(textField.getText());
						setVisible(false);
						
					}
				});
				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
			}
			{
				JButton cancelButton = new JButton("Cancel");
				cancelButton.setActionCommand("Cancel");
				buttonPane.add(cancelButton);
			}
		}
		
		JButton btnDurchsuchen = new JButton("Durchsuchen");
		btnDurchsuchen.setBounds(405, 93, 113, 23);
		getContentPane().add(btnDurchsuchen);
		
		textField = new JTextField();
		textField.setBounds(21, 94, 374, 20);
		getContentPane().add(textField);
		textField.setColumns(10);
		
		JLabel lblWhlenSieIhren = new JLabel("W\u00E4hlen Sie Ihren Arbeitsplatz");
		lblWhlenSieIhren.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblWhlenSieIhren.setBounds(10, 11, 498, 14);
		getContentPane().add(lblWhlenSieIhren);
		
		JLabel lblNewLabel = new JLabel("W\u00E4hlen Sie Ihren Arbeitspalz aus. In dem Arbeitsplatz befinden sich Ihre Aktuellen Projekte.");
		lblNewLabel.setBounds(11, 36, 496, 33);
		getContentPane().add(lblNewLabel);
		
		getUserPath();
	}
	
	public void getUserPath(){
		Properties p = System.getProperties();
		
		String path = p.getProperty("user.home");
		textField.setText(path + "/djf Projects");
		File f = new File(path + "/djf Projects");
		if (f.exists()==false){
			f.mkdir();	
		}
		
		
		
	}
	
	
}
